import type { Ref } from 'vue'

import { useTable } from '@/hooks/useTable'

export const STRATEGY_LIST_KEY = 'STRATEGY_LIST_KEY'

export interface StrategyItem {
  name: string
  code: string
  remarks?: string
}

export const DEFAULT_STRATEGY_LIST: StrategyItem[] = [
  {
    name: '长赢150',
    code: '150',
    remarks: '存量资金分成150份'
  },
  {
    name: '长赢S',
    code: 'S',
    remarks: '每月结余资金分成2份'
  },
  {
    name: '长赢-网格',
    code: 'net',
    remarks: '适合震荡市，防止坐电梯'
  },
  {
    name: '目标市值',
    code: 'target',
    remarks: '自带低买高卖，按估值来'
  }
]

export const initStrategy = () => {
  const { list } = useTable<StrategyItem>({
    cacheKey: STRATEGY_LIST_KEY,
    defaultList: DEFAULT_STRATEGY_LIST
  }) as { list: Ref<StrategyItem[]> }

  return {
    list
  }

}